package day05.practise;

import java.util.Arrays;

//数组拷贝
//1.System.arrayCopy
//2.Arrays.copyOf
public class ArrayCopy {
    public static void main(String[] args) {
        int [] arr1=new int[]{1,3,5,7};
        int []arr2=MethodOfArrayCopy(arr1);
        int []arr3=MethodOfCopyOf(arr1);
        for (int num:arr2){
            System.out.println(num);
        }
        System.out.println("------------");
        for (int num:arr3){
            System.out.println(num);
        }

    }

    private static int[] MethodOfCopyOf(int[] arr1) {
        arr1=Arrays.copyOf(arr1,arr1.length+2);
        return arr1;
    }

    private static int[] MethodOfArrayCopy(int[] arr1) {
        int[]arr=new int[5];
        System.arraycopy(arr1,1,arr,0,2);
        return arr;
    }

}
